home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
WINSRC20.ZIP
/
MAINFRAC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-20
|
15KB
|
561 lines
/*
non-windows main driver of Fractint for Windows -
*/
#define PUTTHEMHERE 1 /* stuff common external arrays here */
/* from MSC's <dos.h> */
#define FP_SEG(fp) (*((unsigned _far *)&(fp)+1))
#define FP_OFF(fp) (*((unsigned _far *)&(fp)))
#include "fractint.h"
#include "fractype.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <search.h>
#include <string.h>
#include <float.h>
#include <ctype.h>
#include <time.h>
int cmp_line(), pot_line();
LPSTR win_lpCmdLine;
extern int time_to_restart;
extern int time_to_reinit;
extern int time_to_quit;
extern int time_to_load;
extern int time_to_save;
extern int time_to_print;
extern int time_to_cycle;
extern char FileName[];
char string004[2];
extern int xdots, ydots, colors, maxiter;
extern int ytop, ybottom, xleft, xright;
int fractype;
int invert;
double ftemp, xxmin, xxmax, yymin, yymax;
long fudge;
double xfudge;
long xvalue, yvalue, lm, linitx, linity;
int maxit, bitshift, color, row, col;
int calc_status; /* -1 no fractal */
/* 0 parms changed, recalc reqd */
/* 1 actively calculating */
/* 2 interrupted, resumable */
/* 3 interrupted, not resumable */
/* 4 completed */
int reset_periodicity = 1;
extern int kbdcount;
int show_orbit = 0;
int orbit_ptr = 0;
int periodicitycheck;
extern int debugflag;
int integerfractal;
extern int distest;
int oktoprint = 0;
extern int bitshiftless1;
char usr_stdcalcmode, stdcalcmode;
int usr_distest; usr_floatflag, usr_periodicitycheck;
long creal, cimag;
long delx, dely, delx2, dely2, delmin;
long xmin, xmax, ymin, ymax, x3rd, y3rd;
double dxsize, dysize; /* xdots-1, ydots-1 */
double delxx, delyy, delxx2, delyy2, ddelmin, xx3rd, yy3rd;
double param[4];
double potparam[3];
int diskvideo, savedac;
#define MAXLINE 2048
long far *lx0, far *ly0, far *lx1, far *ly1;
double far *dx0, far *dy0, far *dx1, far *dy1;
extern double far temp_array[8001];
unsigned char trigndx[4];
unsigned char dacbox[257][3];
double plotmx1, plotmx2, plotmy1, plotmy2;
int MPOverflow;
int dotmode;
extern int pot16bit;
int andcolor, resave_flag, timer_interval;
int active_ovly;
int extraseg;
int timedsave = 0;
int disk16bit = 0;
extern int initbatch;
float far initifs3d[32][13];
float far initifs[32][7];
extern unsigned char readname[];
unsigned char MAP_name[40] = "";
int rowcount;
int adapter;
extern int showfile;
extern int initmode;
extern int overlay3d;
extern int display3d;
extern int filetype;
int comparegif = 0;
int diskisactive = 0;
extern int initsavetime;
int saveticks = 0;
int savebase = 0;
int zwidth = 0;
extern int (*outln)();
extern int out_line();
extern int outlin16();
static int call_line3d();
extern int line3d();
extern int gifview();
extern int tgaview();
int hasconfig = 0;
FILE *dacfile;
int mapset = 0;
int reallyega = 0;
int loadPalette = 0;
int compiled_by_turboc = 0;
int sxdots,sydots;
int sxoffs=0,syoffs=0;
int viewwindow=0;
float viewreduction=1;
int viewcrop=1;
float finalaspectratio;
int viewxdots=0,viewydots=0;
extern int filexdots, fileydots, filecolors;
int frommandel;
int debug_fastupdate; /* debugging - update every pixel if set */
int onthelist[100]; /* list of available fractal types */
int CountFractalList; /* how many are on the list? */
int CurrentFractal; /* which one is current? */
int Printer_Resolution, Printer_Titleblock, Printer_SFrequency;
int Printer_SetScreen, Printer_SStyle, Printer_Type;
int Printer_ColorXlat, Printer_SAngle, LPTnumber;
int video_type, no_color_text;
int active_system = WINFRAC; /* running under windows */
extern int win_display3d, win_overlay3d;
compare_fractalnames( int *element1, int *element2)
{
int i, j, k;
for (i = 0; i < 100; i++) {
j = *element1;
k = *element2;
if (fractalspecific[j].name[i] < fractalspecific[k].name[i])
return(-1);
if (fractalspecific[j].name[i] > fractalspecific[k].name[i])
return(1);
if (fractalspecific[j].name[i] == 0)
return(0);
}
return(0);
}
fractint_main()
{
int i, j, k;
long newx, newy, newxx, newyy, newxy, temp;
double temp1, temp2;
double dtemp, ccreal, ccimag;
CountFractalList = 0;
for (k = 0; fractalspecific[k].name != NULL; k++)
if (fractalspecific[k].name[0] != '*' &&
(fractalspecific[k].flags & WINFRAC) != 0 &&
CountFractalList < 100)
onthelist[CountFractalList++] = k;
qsort(onthelist,CountFractalList,2,compare_fractalnames);
CurrentFractal = fractype;
lx0 = (long far *)&temp_array[0*MAXLINE];
ly0 = (long far *)&temp_array[1*MAXLINE];
lx1 = (long far *)&temp_array[2*MAXLINE];
ly1 = (long far *)&temp_array[2*MAXLINE];
dx0 = (double far *)&temp_array[0*MAXLINE];
dy0 = (double far *)&temp_array[1*MAXLINE];
dx1 = (double far *)&temp_array[2*MAXLINE];
dy1 = (double far *)&temp_array[2*MAXLINE];
extraseg = FP_SEG(dx0);
restoredac(); /* ensure that the palette has been initialized */
win_cmdfiles(); /* SSTOOLS.INI processing */
initmode = 1; /* override SSTOOLS.INI */
dotmode = 1;
diskvideo = 0;
usr_distest = 0;
/* ----- */
debug_fastupdate = 0;
calc_status = -1;
resave_flag = 1;
strcpy(FileName,"Fract001");
if (showfile != 0) {
strcpy(readname, FileName);
}
else {
if (strchr(readname,'.') == NULL)
strcat(readname,".gif");
strcpy(FileName,readname);
time_to_load = 1;
}
/*
sprintf(strlocn," %d bytes",stackavail());
stopmsg(0,"Available Stack",strlocn);
*/
/* ----- */
time_to_quit = 0;
/* getakey(); (uncomment this to fire up Fractint waiting for instructions) */
if (time_to_quit)
return(0);
reinit:
time_to_reinit = 0;
savedac = 0; /* don't save the VGA DAC */
for (i = 0; i < 4; i++) {
if(param[i] != FLT_MAX)
fractalspecific[fractype].paramvalue[i] = param[i];
else
param[i] = fractalspecific[fractype].paramvalue[i];
}
ccreal = param[0]; ccimag = param[1]; /* default C-values */
frommandel = 0;
if (xxmin > xxmax) {
dtemp = xxmin; xxmin = xxmax; xxmax = dtemp;}
if (yymin > yymax) {
dtemp = yymin; yymin = yymax; yymax = dtemp;}
ytop = 0;
ybottom = ydots-1;
xleft = 0;
xright = xdots-1;
filexdots = xdots;
fileydots = ydots;
filecolors = colors;
restart:
time_to_restart = 0;
if (calc_status == -99)
calc_status = 2; /* force a recalc */
else
calc_status = 0; /* force a restart */
maxit = maxiter;
if (colors == 2 && (fractype == PLASMA || usr_stdcalcmode == 'b'))
colors = 16; /* 2-color mode just doesn't work on these */
andcolor = colors-1;
debug_fastupdate = 0; /* turn off debug-mode screen updates */
if (debugflag == 6666)
debug_fastupdate = 1;
/* compute the (new) screen co-ordinates */
/* correct a possibly munged-up zoom-box outside the image range */
if (ytop >= ydots) ytop = ydots-1;
if (ybottom >= ydots) ybottom = ydots-1;
if (xleft >= xdots) xleft = xdots-1;
if (xright >= xdots) xright = xdots-1;
if (xleft == xright || ytop == ybottom) {
}
if (xleft > xright)
{ i = xleft; xleft = xright; xright = i;}
if (ytop > ybottom)
{ i = ybottom; ybottom = ytop; ytop = i;}
temp1 = xxmin;
temp2 = xxmax - xxmin;
xxmin = temp1 + (temp2 * xleft )/(xdots-1);
xxmax = temp1 + (temp2 * xright)/(xdots-1);
temp1 = yymin;
temp2 = yymax - yymin;
yymin = temp1 + (temp2 * (ydots - 1 - ybottom)/(ydots-1));
yymax = temp1 + (temp2 * (ydots - 1 - ytop )/(ydots-1));
xx3rd = xxmin;
yy3rd = yymin;
xleft = 0;
xright = xdots-1;
ytop = 0;
ybottom = ydots-1;
/*
delxx = (xxmax - xxmin) / (xdots-1);
delyy = (yymax - yymin) / (ydots-1);
delxx2 = delyy2 = 0.0;
ddel